#selenium面向过程
#导入selenium
#打开浏览器 输入网址全称 获取搜索框 输入关键字-天气预报
# 获取百度按钮  获取页面标题，并打印出来   检查python关键字是否在标题中
#关闭浏览器
from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver=webdriver.Chrome()

driver.get('https://www.baidu.com')
time.sleep(2)
kw=driver.find_element(By.ID,'kw')
kw.send_keys('天气预报')
#kw.send_keys('python')
time.sleep(2)
su=driver.find_element(By.ID,'su')
su.click()
print(driver.title)

if 'python' in driver.title:
    print('ok')
else:
    print('no')

time.sleep(2)
driver.quit()

'''
driver=webdriver.Chrome()

driver.get('https://www.so.com/')
time.sleep(2)
kw=driver.find_element(By.ID,'kw')
kw.send_keys('天气预报')
#kw.send_keys('python')
time.sleep(2)
su=driver.find_element(By.ID,'su')
su.click()
print(driver.title)

if 'python' in driver.title:
    print('ok')
else:
    print('no')

time.sleep(2)
driver.quit()
'''

